package net.ivpn.core.v2.splittunneling.holder

/*
 IVPN Android app
 https://github.com/ivpn/android-app

 Created by Oleksandr Mykhailenko.
 Copyright (c) 2023 IVPN Limited.

 This file is part of the IVPN Android app.

 The IVPN Android app is free software: you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by the Free
 Software Foundation, either version 3 of the License, or (at your option) any later version.

 The IVPN Android app is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 details.

 You should have received a copy of the GNU General Public License
 along with the IVPN Android app. If not, see <https://www.gnu.org/licenses/>.
*/

import android.widget.Filter
import androidx.appcompat.widget.SearchView
import androidx.recyclerview.widget.RecyclerView
import net.ivpn.core.databinding.AppsSearchItemBinding

class AppsSearchViewHolder(
        val binding: AppsSearchItemBinding,
        filter: Filter
) : RecyclerView.ViewHolder(binding.root) {

    init {
        binding.search.setOnQueryTextListener(
                object : SearchView.OnQueryTextListener {
                    override fun onQueryTextSubmit(query: String): Boolean {
                        return false
                    }

                    override fun onQueryTextChange(query: String): Boolean {
                        filter.filter(query)
                        return false
                    }

                })

        binding.executePendingBindings()
    }
}